package com.netty.server;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author chengjy
 * @date 2025/4/29
 */
public class BioServer {
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(8080);

        while (true) {
            System.out.println("服务端启动成功");
            Socket accept = serverSocket.accept();
            System.out.println("客户端连接成功:" + accept.toString());
            InputStream inputStream = accept.getInputStream();
            byte[] bytes = new byte[1024];
            int length = 0;
            while ((length = inputStream.read( bytes )) != -1){
                System.out.println(new String(bytes,0,length));
            }
        }
    }
}
